<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=0.5, maximum-scale=0.5">
    <title>{$site.name}</title>
    <link rel="shortcut icon" href="/assets/img/logo.jpg" />
    <!-- Bootstrap Core CSS -->
    <link href="__CDN__/assets/libs/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="__CDN__/assets/css/index.css" rel="stylesheet">
    <style type="text/css" media="all">
        * {
            margin: 0;
            padding: 0;
        }
        .on {
            font-size: 60px;
            font-weight: 500;
            color: #B751F1;
            line-height: 84px;
            letter-spacing: 3px;
            margin-left:20px;
        }

        .btn {
            width: 690px;
            height: 76px;
            background: #B751F1;
            border-radius: 38px;
            text-align: center;
            line-height: 76px;
            color: #ffffff;
            font-size: 30px;


        }

        .btn1 {
            width: 690px;
            height: 76px;
            background: #B751F1;
            border-radius: 38px;
            text-align: center;
            line-height: 76px;
            color: #ffffff;
            font-size: 30px;
            margin: 10px auto;
        }
        .pos{
            width: 686px;
            height:96px;
            background: #F7F8F9;
            border: none;
            outline: none;
            font-size: 26px;
            text-align: center
        }
        
        .notclick {
            pointer-events: none;
        }
    </style>

    <script typet="text/javascript" src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>

<body>
    <div style="display: flex;align-items: center;margin-top: 150px;margin-left: 34px;">
        <img src="/assets/img/logo.jpg" alt="" style="width: 241px;height: 216px;">
        <div>
            <div class="on">注册账号</div>
        </div>
    </div>
    <div style="text-align: center;margin-top: 116px;">
        <input type="text" id="phone" maxlength="11" placeholder="请输入您的手机号码…" style="width: 686px;
        height: 96px;
        background: #F7F8F9;
        border-radius: 12px;border: none;outline: none;font-size: 32px;padding-left: 32px;">
    </div>
    <div style="margin: 40px auto;width: 690px;background: #F7F8F9;border-radius: 12px;display: flex;align-items: center;justify-content: space-between;">
        <input type="text" id="code" placeholder="验证码" style="
        height: 96px;
        background: #F7F8F9;
        border-radius: 12px;border: none;outline: none;font-size: 32px;padding-left: 32px;">
        <div class="wp" style="font-size: 32px;color: #000000;padding-right: 20px;">获取验证码</div>
    </div>

<!--    <div style="text-align: center;margin-top: 30px">-->
<!--        <input type="text" id="init_code" placeholder="请输入您的专属邀请码(非必填)" style="width: 686px;-->
<!--        height: 96px;-->
<!--        background: #F7F8F9;-->
<!--        border-radius: 12px;border: none;outline: none;font-size: 32px;padding-left: 32px;" value="{$invite}" readonly>-->
<!--    </div>-->
<!--    <div style="text-align: center;margin-top: 30px">-->
<!--        <input type="text" placeholder="请选择您的身份" list="postion" class="pos" value="{$postion}">-->
<!--        <datalist id="postion" >-->
<!--             <option>用户</option>-->
<!--            <option>技师</option>-->
<!--            <option>商家</option>-->
<!--        </datalist>-->

<!--    </div>-->
    <div style="text-align: center;margin-top: 30px;" >
        <div class="btn" style="margin: 20px auto">立即注册</div>
    </div>

</body>
<script>
    $('.wp').click(function () {
        var wp = document.getElementsByClassName('wp')[0];
        var phone = $('#phone').val();
        if (!phone) {
            alert('请输入手机号');
            return;
        }
        let time = 10;
        $.ajax({
            url: "/api/sms/send",
            type: "post",
            dataType: "json",
            data: { mobile: phone, event: "register" },
            success: function (data) {
                if(data.code == 1){
                    $('.wp').addClass('notclick');
                }
                alert(data.msg);
            }
        });
        const timer = setInterval(() => {
            time--;
            if (time <= 0) {
                wp.innerHTML = "重新获取验证码"
                clearInterval(timer);
                $('.wp').removeClass('notclick');
            } else {
                if (time < 10) {
                    wp.innerHTML = "0" + time + "s后重新获取"
                } else {
                    wp.innerHTML = time + "s后重新获取"
                }
            }
            console.log(time);
        }, 1000);
    })
    $('.btn').click(function () {
        var phone = $('#phone').val();
        var init_code = $('#init_code').val();
        var postion = $('#postion').val();
        if (!phone) {
            alert('请输入手机号');
            return;
        }
        var code = $('#code').val();
        if (!code) {
            alert('请输入验证码');
            return;
        }
        $.ajax({
            url: "/index/index/register",
            type: "post",
            dataType: "json",
            data: { mobile: phone, captcha: code, invite:init_code,postion:postion},
            success: function (data) {
                alert(data.msg)
                console.log(data);
                if(data.code==1){
                    if(data.postion==1) {
                        window.location.href = 'http://fir.zzzywqj.com/c8ne';
                    }else if(data.postion==2){
                        window.location.href = 'http://fir.zzzywqj.com/c8ne';
                    }else if(data.postion==3){
                        window.location.href = 'http://fir.zzzywqj.com/c8ne';
                    }
                }
            },
            fail: function (msg) {
                alert(msg);

            }
        });
    })
</script>

</html>